﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace System.Web.Mvc
{
    public static class UEditorHelper
    {
        /// <summary>
        /// 百度UEditor富文本编辑器
        /// </summary>
        public static MvcHtmlString UEditor(this HtmlHelper helper, string name)
        {
            return UEditor(helper, name, "");
        }

        /// <summary>
        /// 百度UEditor富文本编辑器
        /// </summary>
        public static MvcHtmlString UEditor(this HtmlHelper helper, string name, string value)
        {
            //            string html =
            //                      @"<div><textarea name=""" + name + @""" id=""" + name + @""">" + value + "</textarea></div>"
            //                    + @"<script type= ""text/javascript"">"
            //                    + @" $(document).ready(function () {
            //                             var editor = new UE.ui.Editor(); 
            //                             editor.render(""" + name + @"""); 
            //                         } )   "
            //                    + @"</script>";


            string html = @" 
  <script id=""" + name + @""" name=""" + name + @""" type=""text/plain"">
        " + value + @"
    </script> 
 
    <script type=""text/javascript"">
        var ue = UE.getEditor('" + name + @"');
    </script>

";

            return new MvcHtmlString(html);
        }
    }
}